package com.douqu.game.core.factory;


import com.douqu.game.core.config.AssetConfig;
import com.douqu.game.core.config.challenge.MapConfig;
import com.douqu.game.core.entity.GMSetting;
import com.douqu.game.core.util.LogUtils;

/**
 * Created by bean on 2016/11/24.
 */
public class ConfigFactory {

    public static String LANGUAGE = ConstantFactory.LANGUAGE_CHINESE;

    /**
     * 引擎版本
     */
    public static String ENGINE;

    /**
     * 主服，活动服，战斗服都需要
     */
    public static int SERVER_PORT_MAIN;

    /**
     * GM服务器，集成在主服里
     */
    public static int SERVER_PORT_GM;

    /**
     * 主服，活动服，战斗服都需要
     */
    public static int SERVER_PORT_RMI;
    /**
     * RMI隐藏端口，RMI另外需要的一个端口,主服和活动服需要
     */
    public static int SERVER_PORT_RMI_HIDE;

    /**
     * 主服，活动服，战斗服都需要
     */
    public static String SERVER_URL_RMI;

    /**
     * 战斗TCP服务器端口(主服和活动服保存的)
     */
    public static int[] SERVER_PORT_BATTLE;

//    /**
//     * 活动服配置的战斗服务器地址(通知给客户端的)
//     */
//    public static String SERVER_HOST_BATTLE;

    public static String LOG_PATH;








    /**
     * 钻石对应的资源ID(要特殊处理,在player里的money字段也存一份)
     */
    public static final int ASSET_MONEY_KEY = 1;
    /**
     * 主角经验
     */
    public static final int ASSET_EXP_KEY = 2;
    /**
     * 官阶战积分
     */
    public static final int ASSET_INTEGRAL_KEY = 103;
    /**
     * 功勋(阵营战获得)
     */
    public static final int ASSET_EXPLOIT_KEY = 106;

    /**
     * 竞技场地图ID
     */
    public static final int BATTLE_MAP_ARENA = 1;

    /**
     * 最大玩家等级
     */
    public static int MAX_PLAYER_LV;


//    /**
//     * 阵营活动ID
//     */
//    public static int CAMP_ACTIVITY_ID;


    /** 大地图进城等待时间*/
    public static int WORLD_MAP_STATUS_WAIT_TIME;
    /** 战斗等待时间 */
    public static int WORLD_MAP_BATTLE_WAIT_TIME;
    /** 撤退生命比例 */
    public static int WORLD_MAP_BREAK_HP_RATE;
    /** 突破人数限制 */
    public static int WORLD_MAP_BREAK_PERSON_MULT;

    /**
     * 大地图刷新间隔时间
     */
    public static int[] WORLD_MAP_FLUSH_TIME;

    /** 邮件等级 0不加后缀 1充值大于6块加后缀 */
    public static int MAIL_LEVEL;

    public static GMSetting gmSetting = new GMSetting();


    public static void check(DataFactory dataFactory)
    {
        if(dataFactory.getGameObject(DataFactory.ASSET_KEY, ASSET_MONEY_KEY) == null)
        {
            LogUtils.error("Load Asset Error ASSET_MONEY_KEY not found!");
            dataFactory.addError(AssetConfig.class.getSimpleName(), "check", "error", ASSET_MONEY_KEY);
        }

        if(dataFactory.getGameObject(DataFactory.ASSET_KEY, ASSET_EXP_KEY) == null)
        {
            LogUtils.error("Load Asset Error ASSET_EXP_KEY is null!");
            dataFactory.addError(AssetConfig.class.getSimpleName(), "check", "error", ASSET_EXP_KEY);
        }


        if(dataFactory.getGameObject(DataFactory.ASSET_KEY, ASSET_INTEGRAL_KEY) == null)
        {
            LogUtils.error("Load Asset Error ASSET_INTEGRAL_KEY not found!");
            dataFactory.addError(AssetConfig.class.getSimpleName(), "check", "error", ASSET_INTEGRAL_KEY);
        }

        if(dataFactory.getGameObject(DataFactory.ASSET_KEY, ASSET_EXPLOIT_KEY) == null)
        {
            LogUtils.error("Load Asset Error ASSET_EXPLOIT_KEY not found!");
            dataFactory.addError(AssetConfig.class.getSimpleName(), "check", "error", ASSET_EXPLOIT_KEY);
        }


        if(dataFactory.getGameObject(DataFactory.MAP_KEY, BATTLE_MAP_ARENA) == null)
        {
            LogUtils.error("Load Map Error BATTLE_MAP_ARENA not found!");
            dataFactory.addError(MapConfig.class.getSimpleName(), "check", "error", BATTLE_MAP_ARENA);
        }

        //dataFactory.checkGoblinStoreConfig();

        MAX_PLAYER_LV = DataFactory.getInstance().getDataList(DataFactory.PLAYER_LV_KEY).size();

    }

}
